package value

import (
	"bytes"
	"context"
)

type NixList []NixValue

func (NixList) NixType() string {
	return "list"
}

func (l NixList) String() string {
	var buf bytes.Buffer
	buf.WriteString("[ ")

	for _, elem := range l {
		buf.WriteString(elem.String())
		buf.WriteByte(' ')
	}

	buf.WriteString("]")
	return buf.String()
}

func (l NixList) Strict(ctx context.Context) error {
	var err error
	for _, elem := range l {
		// TODO: concurrent?)
		err = elem.Strict(ctx)
		if err != nil {
			return err
		}
	}

	return nil
}
